import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import login from '../components/login'
import home from '../home/home'
import yb from '../home/yb'
import banner from '../home/banner'
import mings from '../home/mings'
import classlist from '../home/class'
import classtwo from '../home/classtwo'
import classall from '../home/classall'
import reclass from '../home/reclass';

Vue.use(Router)
const routers = new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: login
    }, {
      path: '/home',
      name: 'home',
      component: home,
      children: [
        {
          path: '/yb',
          name: 'yb',
          component: yb
        }, {
          path: '/banner',
          name: 'banner',
          component: banner
        }, {
          path: '/mings',
          name: 'mings',
          component: mings
        }, {
          path: '/classlist',
          name: 'classlist',
          component: classlist
        }, {
          path: '/classtwo',
          name: 'classtwo',
          component: classtwo
        }, {
          path: '/classall',
          name: 'classall',
          component: classall
        }
        , {
          path: '/reclass',
          name: 'reclass',
          component: reclass
        }
      ]
    }
  ]
})

routers.beforeEach((to, from, next) => {
  if ( to.path == '/' || sessionStorage.getItem('logininfo')) {
    next();
  } else {
    next('/');
  }
})

export default routers
